# -*- coding: utf-8 -*-
#企业证书二级映射
import json

def getMatchList(request):
    #1数据
    request.cursor_standard.execute(request.formatSql('''
        select * from middle.company_apt_un_match_second 
        where data_source_code = '${data_source_code}'
        order by data_source_code ,original 
        limit ${start} , ${rows} 
    '''))
    rows = request.cursor_standard.fetchall()
    #2页码
    request.cursor_standard.execute(request.formatSql('''
        select count(*) as  total 
        from middle.company_apt_un_match_second 
        where data_source_code = '${data_source_code}'
    '''))
    total = request.cursor_standard.fetchone()['total']

    return json.dumps({'rows':rows,'total':total}, ensure_ascii=False)

def updateDataSource(request):
    request.cursor_standard.execute(request.formatSql('''
        update middle.company_apt_un_match_second 
        set target = '${name2}'  
        where id = ${id}
    '''))
    return str(request.cursor_standard.rowcount)
